package ru.susu.algebra.chartable;

import java.util.ArrayList;

/**
 * @author akargapolov
 * @since: 03.03.2009
 */
public class SymmetricGroupArrayListBasedCharTable<V> extends PermGroupCharTableBase<V>
{
	private ArrayList<Object[]> _data;

	private Integer _size;

	public SymmetricGroupArrayListBasedCharTable(int size)
	{
		super();
		_size = size;
		_data = new ArrayList<Object[]>(_size);
		for (int i = 0;i<_size;i++)
		{
			_data.add(null);
		}
	}

	public Integer getSize()
	{
		return _size;
	}

	@Override
	public V getCharacter(int row, int col)
	{
		this.checkCell(row, col);
		return (V)_data.get(col)[row];
	}

	@Override
	public void setCharacter(int row, int col, V value)
	{
		this.checkCell(row, col);
		_data.get(col)[row] = value;
	}

	private void checkCell(int row, int col)
	{
		if (_data.get(col) == null)
		{
			_data.set(col, new Long[_size]);
		}
	}
}
